package com.qingcheng.controller.order;

import com.alibaba.dubbo.config.annotation.Reference;
import com.qingcheng.entity.Result;
import com.qingcheng.service.order.OrderService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

/**
 * @ProjectName: qingcheng_parent
 * @ClassName: OrderTask
 * @Time: 2019/7/1
 * @Author: zhou24
 * @Description:
 * @Experience:
 */
@Component
@RequestMapping("/OrderTask")
public class OrderTask {

    @Reference
    private OrderService orderService;

//    @Scheduled(cron = "0 0/2 * * * ? ")(每俩分钟执行一次)
    public Result orderTimeOutLogic(){
        System.out.println("每两分钟间隔执行一次任务"+ new Date());
        orderService.orderTimeOutLogic();
        return new Result();
    }

//    @Scheduled(cron = "0 0 1 * * ? ")
    @GetMapping("/orderCountTest")
    @ResponseBody
    public Result orderCount(){
        System.out.println("每天晚上1：00执行一次任务"+ new Date());
        orderService.orderCount();
        return new Result();

    }

}
